﻿namespace IBBI.DataBase.Enumeration {

    public class Permission {

        public static readonly int Read   = 1;
        public static readonly int Create = 1 << 1;
        public static readonly int Update = 1 << 2;
        public static readonly int Delete = 1 << 3;
        public static readonly int Admin  = (Read | Create | Update| Delete);

        public int Value { get; set; }

        public bool GetPermission(int permission) {
            return ( Value & permission ) > 0;
        }

        public void SetPermission(int permission, bool set) {
            if (set) {
                Value &= permission;
            }
            else {
                Value |= ~permission;
            }
        }
    }
}